<?php

namespace app\admin\validate\level;

use think\Validate;


class Config extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'standard'  => 'checkStandard:thinkphp',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        "standard.format"=>"只能输入波浪线和数字"
    ];
    /**
     * 自定义验证规则
     */
    protected function checkStandard($value,$rule,$data=[])
    {
        if(strstr($value,"~")){
            $str=str_replace('~','',$value);
            if(!preg_match("/[^\d-., ]/",$str)){
                return true;
            }
            return "只能输入波浪线和数字";
        }else{
            return "只能输入波浪线和数字";
        }
    }
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => [],
        'edit' => [],
    ];
    
}
